package com.example.stream.service.impl;

import com.example.stream.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;

@Service
@Slf4j
public class MessageServiceImpl implements MessageService {

    @Resource
    private StreamBridge bridge;

    @Override
    public void sendMail() {
        String serial = UUID.randomUUID().toString();
        boolean result = bridge.send("sendMail-out-0", serial);
        log.info("Send mail, result: {}, serial: {}", result, serial);
    }

    @Override
    public void sendMsg() {
        String serial = UUID.randomUUID().toString();
        boolean result = bridge.send("sendMsg-out-0", serial);
        log.info("Send msg, result: {}, serial: {}", result, serial);
    }
}
